<%@ page language="java" contentType="text/html; charset=UTF-8"	 pageEncoding="UTF-8"%>
<%@ include file="../include/laypublic.jsp"%>
<!DOCTYPE html>
<html>
<head>
  <title>商务成本统计表</title>
  <style type="text/css">
  </style>
</head>
<body>
  <div class="layui-fluid">   
    <div class="layui-card">
      <!-- 查询区域  -->
      <div id="query-form" class="layui-form layui-card-header layuiadmin-card-header-auto">
        <div class="layui-form-item">
          <div class="layui-inline">
            	<label class="layui-form-label">统计月份</label>
            	<div class="layui-input-inline">
              		<input type="text" class="layui-input" id="sts_month_start"  name="stsMonthStart" readonly placeholder="开始月份">
            	</div>
            	<div class="layui-form-mid">
               	-
            	</div>
            	<div class="layui-input-inline">
              		<input type="text" class="layui-input" id="sts_month_end" name="stsMonthEnd" readonly placeholder="结束月份">
            	</div>
          </div>
          <div class="layui-inline">
            	<label class="layui-form-label">公司主体</label>
            	<div class="layui-input-inline" style="width:260px;">
              		<select name="orgTypeAndId" id="query_select_orgId" lay-filter="query_select_orgId" lay-search >
	              		<c:if test="${not empty orgInfos }">
	              			<c:forEach items="${orgInfos}" var="org">
	              				<option value="${org.id}-${org.types}" <c:if test="${org.id == bindOrgId }">selected</c:if>>${org.compName }</option>
		            		</c:forEach>
	              		</c:if>
	              	</select>
            	</div>
          	</div>
          	<div class="layui-inline">
            	<label class="layui-form-label">项目名称</label>
            	<div class="layui-input-inline">
              		<input type="text" name="orgProName" id="query_input_orgProName"  placeholder="请输入" autocomplete="off" class="layui-input" >
            	</div>
          	</div>
          	<shiro:hasPermission name="LIST_COST_COLLECT">
	          <div class="layui-inline">
	            <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="LAY-costCollect-search">
	              <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
	            </button>
	          </div>
          	</shiro:hasPermission>
        </div>
      </div>
      <div class="layui-card-body">
        <table id="LAY-costCollect-manage" lay-filter="LAY-costCollect-manage"></table>
      </div>
    </div>
  </div>

  <script>
  var stageJSON = <infopub:dicJson groupNo="A00010077" />;
  	layui.config({
    	base: '${ctx}/resources/layuiadmin/' //静态资源所在路径
  	}).extend({
    	index: 'lib/index' //主入口模块
  	}).use(['index', 'table', 'set', 'laydate', 'element'], function(){
    	var $ = layui.$
    	,form = layui.form
    	,table = layui.table
    	,laydate = layui.laydate
    	,element = layui.element;
    	
    	var insStart = laydate.render({
	      elem: '#sts_month_start'
	      ,type: 'month'
	      ,btns: ['now', 'confirm']
	      ,format:'yyyy年MM月'
	      ,value: layui.util.toDateString(new Date().getTime() - 2592000000 , 'yyyy年MM月') //30天前
	      ,done:function(value, date){
	    	  //更新结束日期的最小日期
  	          insEnd.config.min = lay.extend({}, date, {
  	              month: date.month - 1
  	          });
	  	        
  	          //自动弹出结束日期的选择器
	  	      insEnd.config.elem[0].focus();
  	          
	      	  table.reload('LAY-costCollect-manage', {page: {curr: 1},
			 	 where: {'stsMonthStart':value,'stsMonthEnd':$("#sts_month_end").val(),'orgTypeAndId':$('#query_select_orgId').val(),'orgProName':$('#query_input_orgProName').val()}
		      });
	      }
	    });
	    
    	var insEnd = laydate.render({
	      elem: '#sts_month_end'
	      ,type: 'month'
	      ,btns: ['now', 'confirm']
	      ,format:'yyyy年MM月'
	      ,value: layui.util.toDateString(new Date().getTime() - 2592000000 , 'yyyy年MM月') //30天前
	      ,done:function(value, date){
	    	  //更新开始日期的最大日期
        	  insStart.config.max = lay.extend({}, date, {
	  	          month: date.month - 1
	  	      });
	    	  
	      	  table.reload('LAY-costCollect-manage', {page: {curr: 1},
			 	 where: {'stsMonthStart':$("#sts_month_start").val(),'stsMonthEnd':value,'orgTypeAndId':$('#query_select_orgId').val(),'orgProName':$('#query_input_orgProName').val()}
		      });
	      }
	    });
	    
		form.on('select(query_select_orgId)', function(data){
   		 	table.reload('LAY-costCollect-manage', {page: {curr: 1},
		 		where: {'stsMonthStart':$('#sts_month_start').val(),'stsMonthEnd':$('#sts_month_end').val(),'orgTypeAndId':$('#query_select_orgId').val(),'orgProName':$('#query_input_orgProName').val()}
	      	});
    	});
		
		var stsMonthStart = $('#sts_month_start').val();
		var stsMonthEnd = $('#sts_month_end').val();
    	// 表单
    	table.render({
      		elem: '#LAY-costCollect-manage'
      		,url: basePath + '/costCollect/queryDataByCondition' //请求数据接口
      		,where: {'stsMonthStart':stsMonthStart,'stsMonthEnd':stsMonthEnd,'orgTypeAndId':$('#query_select_orgId').val(),'orgProName':$('#query_input_orgProName').val()}
      		,cols: [[
				{type:'numbers', title: '序号',fixed:'left', width: 80, align:'center'}
				,{field: 'proName', title: '项目名称',fixed:'left',width: 190, align:'center'}
				,{field: 'hrOrgAreaName', title: '区域公司',fixed:'left',width: 190, align:'center'}
				,{field: 'caeAmount', title: '建安费（元）',width: 190, align:'center', templet: function(d){
					    return formatCurrency(d.caeAmount);
					}
				}
				,{field: 'replaceAmount', title: '代付费（元）',width: 190, align:'center',templet: function(d){
					    return formatCurrency(d.replaceAmount);
					}
				}
				,{field: 'preAmount', title: '前期费（元）',width: 190, align:'center',templet: function(d){
					    return formatCurrency(d.preAmount);
					}
				}
				,{field: 'deviceAmount', title: '专业设备采购费（元）',width: 190, align:'center',templet: function(d){
				    return formatCurrency(d.deviceAmount);
					}
				}
				,{field: 'sumTotalAmount', title: '合计（元）',width: 190, align:'center',templet: function(d){
				    return formatCurrency(d.sumTotalAmount);
					}
				}]]
      		,page: true
      		,limit: 10
    	});
    
    	<shiro:hasPermission name="LIST_COST_COLLECT">
	    	//监听搜索
	    	form.on('submit(LAY-costCollect-search)', function(data){
		      	//执行重载
		      	table.reload('LAY-costCollect-manage', {page: {curr: 1},
		        	where: trimData(data)
		      	});
	    	});
    	</shiro:hasPermission>
  });
  	
  </script>
</body>
</html>

